//
//  AppNetworkingManager+OAPublic.m
//  OANetworkManager_Example
//
//  Created by TFAppleWork-Summer on 2018/3/7.
//  Copyright © 2018年 GuoRui. All rights reserved.
//

#import "AppNetworkingManager+OAPublic.h"
#import "OAExceptionReportDetailModel.h"
#import "OADailyReportDetailModel.h"
#import "OALeaveReportDetailModel.h"
#import "OAOvertimeReportDetailModel.h"

@implementation AppNetworkingManager (OAPublic)

+(TFRequest *)commmonGetInfoWithReportId:(NSString *)reportId
                                    type:(NSInteger)reportType
                                complete:(OANetworkingObjectBlock)complet{
    
    NSDictionary *param = @{@"id":reportId,
                            @"type":@(reportType)};
    
    return [self startRequestWithParams:param
                            path:@"common/getInfo"
              responseObjectPath:@"data"
           popoverProgressString:nil
        handleErrorAutomatically:OANETWORKMANAGERSHOWHUD
                   responseBlock:^(id response, NSError *error) {
                       id detailModel ;
                       switch (reportType)
                       {
                           case 100:
                           {
                               detailModel = [OAExceptionReportDetailModel modelWithDict:response];
                           }
                               break;
                           case 101:
                           {
                               detailModel = [OADailyReportDetailModel modelWithDict:response];
                           }
                               break;
                           case 102:
                           {
                               detailModel = [OALeaveReportDetailModel modelWithDict:response];
                           }
                               break;
                           case 103:
                           {
                               detailModel = [OAOvertimeReportDetailModel modelWithDict:response];
                           }
                               break;
                           default:
                               break;
                       }
                    
                       complet(detailModel,error);
                       
                   }];
}

+(TFRequest *)commonDelteWithReportId:(NSString *)reportId
                                 type:(NSInteger)reportType
                             complete:(OANetworkingObjectBlock)complete{
    NSDictionary *param = @{@"id":reportId,
                            @"type":@(reportType)};
    return [self startRequestWithParams:param
                                   path:@"common/del"
                     responseObjectPath:nil
                  popoverProgressString:nil
               handleErrorAutomatically:OANETWORKMANAGERSHOWHUD
                          responseBlock:^(id response, NSError *error) {
                              if (error) {
                                  complete(@(NO),error);
                              }
                              else{
                                  complete(@(YES),nil);
                              }
                              
                          }];

}

@end
